home *** CD-ROM | disk | FTP | other *** search
- REM ZBasic Quick Finder
- REM ©MacTutor and Zedcor, 1987
- REM Adapted from E-159 of ZBasic Manual
- REM By Dave Kelly
-
- REM This program allows you to Execute other applications
- REM and return with all variables as they were
- REM THIS APPLICATION MUST BE IN SYSTEM FOLDER TO WORK WITH HFS
- REM NOTE: ALL VARIABLES ARE RESTORED UPON RETURN TO THIS PROGRAM
-
- WINDOW OFF
- WINDOW#1,"",(100,30)-(400,90),2
- CurApName&=&910
- FinderName&=&2E0
- I=0
- FirstVariable%=0
- GOSUB "Get Last Variable pointer"
-
- REM Check to see if returning from another application
- OPEN"R",1,"ZVARS" REM If returning from an application
- LONG IF LOF(1,1)>10 REM reload all the variables
- READ FILE #1,VARPTR(FirstVariable%), LastVariable&-VARPTR(FirstVariable%)
- TEXT 2,12,1
- PRINT"Last Application: ";:PRINT Application$
- PRINT"Elapsed Time: ";TIMER-StartTime&;" Seconds"
- XELSE
- TEXT 2,12,1
- PRINT SPC(5);"Welcome to Macintosh."
- SysLength=PEEK(FinderName&)
- SystemFinder$=""
- FOR I=1 TO SysLength
- SystemFinder$=SystemFinder$+CHR$(PEEK(FinderName&+I))
- NEXT
- REM SystemFinder$ is the name of the original Startup appl.
- END IF
- PRINT"Please select an application to run."
- StartTime&=TIMER
-
- REM Moves This Applications filename to FinderName global variable
- FOR I=0 TO 15: REM Your filename MUST be less than 16 char's
- POKE FinderName&+I,PEEK(CurApName&+I)
- NEXT
- REM *** Get name of application to execute
- Application$=FILES$(1,"APPL",,Volume%):REM APPL=any executable file
- REM Last variable used as dummy for READ FILE and WRITE FILE
- LONG IF Application$=""
- CLOSE #1
- KILL "ZVARS"
- REM Restore Finder filename as desktop start-up
- POKE FinderName&,SysLength
- FOR I=1 TO LEN(SystemFinder$)+1
- POKE FinderName&+I,PEEK(VARPTR(SystemFinder$)+I)
- NEXT
- XELSE
- RECORD#1,0,0:REM Reset file pointer to beginning of file
- REM *** Save Variables before executing Application
- WRITE FILE #1,VARPTR(FirstVariable%), LastVariable&-VARPTR(FirstVariable%)
- CLOSE#1
- REM Execute Application now...
- RUN Application$,Volume%
- END IF
- END
- "Get Last Variable pointer"
- LastVariable&=VARPTR(LastVariable%)
- RETURN